package cn.org.eshow.webapp.action.h5;

import cn.org.eshow.bean.query.ProductQuery;
import cn.org.eshow.model.Product;
import cn.org.eshow.service.ProductManager;
import cn.org.eshow.webapp.action.BaseAction;
import org.apache.struts2.convention.annotation.AllowedMethods;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.List;

/**
 * 商品订单 H5接口
 */
@Results({@Result(name = "input", location = "add"),
        @Result(name = "list", type = "redirect", location = ""),
        @Result(name = "success", type = "redirect", location = "view/${id}"),
        @Result(name = "redirect", type = "redirect", location = "${redirect}")})
@AllowedMethods({"pay", "view"})
public class ProductAction extends BaseAction {

    private static final long serialVersionUID = 1L;

    @Autowired
    private ProductManager productManager;

    private Product product = new Product();
    private List<Product> products = new ArrayList<Product>();
    private ProductQuery query = new ProductQuery(Boolean.TRUE);

    public String view() {
        product = productManager.get(id);
        return NONE;
    }

    public Product getProduct() {
        return product;
    }

    public void setProduct(Product product) {
        this.product = product;
    }

    public List<Product> getProducts() {
        return products;
    }

    public void setProducts(List<Product> products) {
        this.products = products;
    }

    public ProductQuery getQuery() {
        return query;
    }

    public void setQuery(ProductQuery query) {
        this.query = query;
    }


}